package com.zyz.I_多线程.死锁;

/**
 * @author: vick
 * @Date: 2025/3/24
 * @Description:
 * @version: 1.0
 */
public class B {
    public synchronized void test(A a) {
        System.out.println("当前线程名称：" + Thread.currentThread().getName() + "进入了B实例的test方法");
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("当前线程名称：" + Thread.currentThread().getName() + "想要调用了A实例的last方法");
        a.last();
    }


    public synchronized void last() {
        System.out.println("B实例的last方法");
    }
}
